<?php

namespace frontend\controllers;

use bc\controller\WxOAuthController;
use bc\model\ProductModel;
use yii\web\Session;
use bc\controller\FrontController;

class CartController extends FrontController
{
	/**
	 * 加入购物车
	 */
	public function actionAdd()
	{
		$product_id = $this->get('product_id', 0);
		$num = $this->get('num', 0);
		if($num < 0)
			$num = 0;
		
		$productModel = new ProductModel();
		
		
	}
	
	
	/**
	 * 从购物车中移除
	 */
	public function actionRemove()
	{
		
	}
	
	
	
	/**
	 * 清空购物车
	 */
	public function actionClean()
	{
		
	}
	
	public function actionTest()
	{
		$session = new Session();
		$cart = $session->get('cart');
		print_r(json_decode($cart, true));
	}
	
	public function actionAddcart()
	{
		$cart[1]['num'] = 20;
		$session = new Session();
		$session->set('cart', json_encode($cart));
		echo 'add success';
	}
}

